USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[StoresClassifications-Insert]    Script Date: [[20120714223941]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223941]]
-- Description:	Insert record into table [dbo].[StoresClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[StoresClassifications-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[StoresClassifications-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[StoresClassifications-Insert]
	/*@StoreClassification_RowNumber int =Null OUTPUT , 
	@StoreClassification_ID uniqueidentifier =Null  , 
	@StoreClassification_ParentID uniqueidentifier =Null  , 
	@StoreClassification_Code varchar(50) =Null  , 
	@StoreClassification_NameAr varchar(300) =Null  , 
	@StoreClassification_NameEn varchar(300) =Null  , 
	@StoreClassification_Notes varchar(max) =Null  , 
	@StoreClassification_Search varchar(max) =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[StoresClassifications](/*[StoreClassification_ID], [StoreClassification_ParentID], [StoreClassification_Code], [StoreClassification_NameAr], [StoreClassification_NameEn], [StoreClassification_Notes], [StoreClassification_Search]*/)
	VALUES     (/*@StoreClassification_ID, @StoreClassification_ParentID, @StoreClassification_Code, @StoreClassification_NameAr, @StoreClassification_NameEn, @StoreClassification_Notes, @StoreClassification_Search*/)

	/*SELECT @StoreClassification_RowNumber = [StoreClassification_RowNumber]
    FROM [dbo].[StoresClassifications]
    WHERE  ( [StoreClassification_ID] =@StoreClassification_ID )
	AND  ( [StoreClassification_ParentID] =@StoreClassification_ParentID )
	AND  ( [StoreClassification_Code] =@StoreClassification_Code )
	AND  ( [StoreClassification_NameAr] =@StoreClassification_NameAr )
	AND  ( [StoreClassification_NameEn] =@StoreClassification_NameEn )
	AND  ( [StoreClassification_Notes] =@StoreClassification_Notes )
	AND  ( [StoreClassification_Search] =@StoreClassification_Search )*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[StoresClassifications-update]    Script Date: [[20120714223941]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223941]]
-- Description:	Update record in table [dbo].[StoresClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[StoresClassifications-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[StoresClassifications-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[StoresClassifications-update]
	/*@StoreClassification_RowNumber int =Null OUTPUT , 
	@StoreClassification_ID uniqueidentifier =Null  , 
	@StoreClassification_ParentID uniqueidentifier =Null  , 
	@StoreClassification_Code varchar(50) =Null  , 
	@StoreClassification_NameAr varchar(300) =Null  , 
	@StoreClassification_NameEn varchar(300) =Null  , 
	@StoreClassification_Notes varchar(max) =Null  , 
	@StoreClassification_Search varchar(max) =Null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/**/
		Update [dbo].[StoresClassifications] SET 
		/*[StoreClassification_ID] =@StoreClassification_ID, 
		[StoreClassification_ParentID] =@StoreClassification_ParentID, 
		[StoreClassification_Code] =@StoreClassification_Code, 
		[StoreClassification_NameAr] =@StoreClassification_NameAr, 
		[StoreClassification_NameEn] =@StoreClassification_NameEn, 
		[StoreClassification_Notes] =@StoreClassification_Notes, 
		[StoreClassification_Search] =@StoreClassification_Search*/
		/*WHERE ([StoreClassification_ID] = @StoreClassification_ID)*/
	/**/

	/*SELECT @StoreClassification_RowNumber = [StoreClassification_RowNumber]
    FROM [dbo].[StoresClassifications]
	WHERE ([StoreClassification_ID] = @StoreClassification_ID)*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[StoresClassifications-Insert-Update]    Script Date: [[20120714223941]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223941]]
-- Description:	Insert OR Update record into table [dbo].[StoresClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[StoresClassifications-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[StoresClassifications-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[StoresClassifications-Insert-Update]
	/*@StoreClassification_RowNumber int =Null OUTPUT , 
	@StoreClassification_ID uniqueidentifier =Null  , 
	@StoreClassification_ParentID uniqueidentifier =Null  , 
	@StoreClassification_Code varchar(50) =Null  , 
	@StoreClassification_NameAr varchar(300) =Null  , 
	@StoreClassification_NameEn varchar(300) =Null  , 
	@StoreClassification_Notes varchar(max) =Null  , 
	@StoreClassification_Search varchar(max) =Null  , 
	@Inserted bit OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[StoresClassifications] 
					/*WHERE ([StoreClassification_ID] = @StoreClassification_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[StoresClassifications](/*[StoreClassification_ID], [StoreClassification_ParentID], [StoreClassification_Code], [StoreClassification_NameAr], [StoreClassification_NameEn], [StoreClassification_Notes], [StoreClassification_Search]*/)
		VALUES     (/*@StoreClassification_ID, @StoreClassification_ParentID, @StoreClassification_Code, @StoreClassification_NameAr, @StoreClassification_NameEn, @StoreClassification_Notes, @StoreClassification_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/**/
			Update [dbo].[StoresClassifications] SET 
			/*[StoreClassification_ID] =@StoreClassification_ID, 
			[StoreClassification_ParentID] =@StoreClassification_ParentID, 
			[StoreClassification_Code] =@StoreClassification_Code, 
			[StoreClassification_NameAr] =@StoreClassification_NameAr, 
			[StoreClassification_NameEn] =@StoreClassification_NameEn, 
			[StoreClassification_Notes] =@StoreClassification_Notes, 
			[StoreClassification_Search] =@StoreClassification_Search*/
			/*WHERE ([StoreClassification_ID] = @StoreClassification_ID)*/
		/**/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @StoreClassification_RowNumber = [StoreClassification_RowNumber]
    FROM [dbo].[StoresClassifications]
	WHERE ([StoreClassification_ID] = @StoreClassification_ID)*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[StoresClassifications-Delete]    Script Date: [[20120714223941]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223941]]
-- Description:	delete records from table [dbo].[StoresClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[StoresClassifications-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[StoresClassifications-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[StoresClassifications-Delete]
	/*@StoreClassification_RowNumber int =null  , 
	@StoreClassification_ID uniqueidentifier =null  , 
	@StoreClassification_ParentID uniqueidentifier =null  , 
	@StoreClassification_Code varchar(50) =null  , 
	@StoreClassification_NameAr varchar(300) =null  , 
	@StoreClassification_NameEn varchar(300) =null  , 
	@StoreClassification_Notes varchar(max) =null  , 
	@StoreClassification_Search varchar(max) =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[StoresClassifications]
	WHERE /*( [StoreClassification_RowNumber] = ISNULL(@StoreClassification_RowNumber, [StoreClassification_RowNumber]) )
	AND ( [StoreClassification_ID] = ISNULL(@StoreClassification_ID, [StoreClassification_ID]) )
	AND ( [StoreClassification_ParentID] = ISNULL(@StoreClassification_ParentID, [StoreClassification_ParentID]) )
	AND ( [StoreClassification_Code] like ISNULL(@StoreClassification_Code, [StoreClassification_Code]) )
	AND ( [StoreClassification_NameAr] like ISNULL(@StoreClassification_NameAr, [StoreClassification_NameAr]) )
	AND ( [StoreClassification_NameEn] like ISNULL(@StoreClassification_NameEn, [StoreClassification_NameEn]) )
	AND ( [StoreClassification_Notes] like ISNULL(@StoreClassification_Notes, [StoreClassification_Notes]) )
	AND ( [StoreClassification_Search] like ISNULL(@StoreClassification_Search, [StoreClassification_Search]) )*/
END
GO
-- =============================================
USE [StoresManagement]
/****** Object:  StoredProcedure [dbo].[StoresClassifications-Select]    Script Date: [[20120714223941]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120714223941]]
-- Description:	select records from table [dbo].[StoresClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[StoresClassifications-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[StoresClassifications-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[StoresClassifications-Select]
	/*@StoreClassification_RowNumber int =null  , 
	@StoreClassification_ID uniqueidentifier =null  , 
	@StoreClassification_ParentID uniqueidentifier =null  , 
	@StoreClassification_Code varchar(50) =null  , 
	@StoreClassification_NameAr varchar(300) =null  , 
	@StoreClassification_NameEn varchar(300) =null  , 
	@StoreClassification_Notes varchar(max) =null  , 
	@StoreClassification_Search varchar(max) =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[StoresClassifications]
	WHERE /*( [StoreClassification_RowNumber] = ISNULL(@StoreClassification_RowNumber, [StoreClassification_RowNumber]) )
	AND ( [StoreClassification_ID] = ISNULL(@StoreClassification_ID, [StoreClassification_ID]) )
	AND ( [StoreClassification_ParentID] = ISNULL(@StoreClassification_ParentID, [StoreClassification_ParentID]) )
	AND ( [StoreClassification_Code] like ISNULL(@StoreClassification_Code, [StoreClassification_Code]) )
	AND ( [StoreClassification_NameAr] like ISNULL(@StoreClassification_NameAr, [StoreClassification_NameAr]) )
	AND ( [StoreClassification_NameEn] like ISNULL(@StoreClassification_NameEn, [StoreClassification_NameEn]) )
	AND ( [StoreClassification_Notes] like ISNULL(@StoreClassification_Notes, [StoreClassification_Notes]) )
	AND ( [StoreClassification_Search] like ISNULL(@StoreClassification_Search, [StoreClassification_Search]) )*/
END
GO
-- =============================================
